﻿
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;

namespace CreateDBFiles
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                using (var db = GetInstance())
                {
                    var df = db.DbFirst;
                    var path = ConfigurationManager.AppSettings["FilePath"].ToString();
                    df.IsCreateAttribute().Where("scada_equipment").CreateClassFile($@"{path}");
                }
            }
            catch (Exception)
            {
                throw;
            }
            Console.WriteLine("生成成功！");
            Console.ReadKey();
        }

        public static SqlSugarClient GetInstance()
        {
            var db = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = _ConnectionString,
                DbType = DbType.PostgreSQL,
                MoreSettings = new ConnMoreSettings 
                { 
                    PgSqlIsAutoToLower = false 
                }
            });
            return db;
        }

        static string _ConnectionString = ConfigurationManager.AppSettings["ConnectStr"].ToString();
    }
}
